import { http } from '@/utils/http'
import type { FormQueryData, QueryParams, RoleMenuIdsData } from './types'

const PATH = '/role'

const RoleAPI = {
  /** 获取列表 */
  getList(params: QueryParams) {
    return http.request<ResponseList>('get', `${PATH}`, { params })
  },
  /** 创建 */
  create(data: FormQueryData) {
    return http.request<ResponseData>('post', `${PATH}`, { data })
  },
  /** 修改 */
  update(id: number, data: FormQueryData) {
    return http.request<ResponseData>('put', `${PATH}/${id}`, { data })
  },
  /** 单选删除 */
  delete(id: number) {
    return http.request<ResponseData>('delete', `${PATH}/${id}`)
  },
  /** 获取菜单列表 */
  getRoleMenu() {
    return http.request<ResponseData>('get', '/role-menu')
  },
  /** 设置权限菜单id */
  setRoleMenuIds(data: RoleMenuIdsData) {
    return http.request<ResponseData>('post', '/set-role-menu-ids', { data })
  },
  /** 获取设置的权限菜单id */
  getRoleMenuIds(id: number) {
    return http.request<ResponseData>("get", `/role-menu-ids/${id}`);
  }

}

export default RoleAPI
